﻿@model smp.ButterflyCakes.Models.ViewModels.Attachments.ViewFilesView
<div class="tab-pane" id="images">
    @if (Model.Images.Count == 0)
    {
        <div class="row-fluid">
            <p>
                No images have been attached to this order.</p>
        </div>
    }
    else
    {
        <div id="imageCarousel" class="carousel slide">
            <ol class="carousel-indicators">
                @for (int i = 0; i < Model.Images.Count; i++)
                {
                    var activeClass = "";
                    if (i == 0)
                    {
                        activeClass = "active";
                    }
                    <li data-target="#imageCarousel" data-slide-to="@i" class="@activeClass"></li>
                }
            </ol>
            <div class="carousel-inner">
                @for (int i = 0; i < Model.Images.Count; i++)
                {
                    var activeClass = "";
                    if (i == 0)
                    {
                        activeClass = "active";
                    }
                    <div class="item @activeClass">
                        <div class="pagelink" url="/order/downloadfile/@Model.Images[i].Id" href="#" data-toggle="tooltip" title="Click to download file">
                            <img src="@Url.Action("GetImage", "Attachment", new { id = Model.Images[i].Id })" alt="" width="100%"/>
                            <div class="carousel-caption">
                                <p class="lead">@Model.Images[i].Description</p>
                            </div>
                        </div>
                    </div>
                }
            </div>
            <a class="left carousel-control" data-slide="prev" href="#imageCarousel">‹</a> <a
                                                                                               class="right carousel-control" data-slide="next" href="#imageCarousel">›</a>
        </div>
    }
</div>

<div class="tab-pane" id="diagrams">
    @if (Model.Diagrams == null || Model.Diagrams.Count == 0)
    {
        <div class="row-fluid">
            <p>No diagrams have been attached to this order</p>
        </div>
    }
    else
    {
        <div id="diagramCarousel" class="carousel slide">
            <ol class="carousel-indicators">
                @for (int i = 0; i < Model.Images.Count; i++)
                {
                    var activeClass = "";
                    if (i == 0)
                    {
                        activeClass = "active";
                    }
                    <li data-target="#diagramCarousel" data-slide-to="@i" class="@activeClass"></li>
                }
            </ol>
            <div class="carousel-inner">
                @for (int i = 0; i < Model.Diagrams.Count; i++)
                {
                    var activeClass = "";
                    if (i == 0)
                    {
                        activeClass = "active";
                    }
                    <div class="item @activeClass">
                        <div class="pagelink" url="/order/ShapeBuilder/@Model.Diagrams[i].ComponentId" href="#" data-toggle="tooltip" title="Click open shape builder">
                            @MvcHtmlString.Create(Model.Diagrams[i].Html)
                            <div class="carousel-caption">
                                <p class="lead">@Model.Diagrams[i].Description</p>
                            </div>
                        </div>
                    </div>
                }
            </div>
            <a class="left carousel-control" data-slide="prev" href="#imageCarousel">‹</a> <a
                                                                                               class="right carousel-control" data-slide="next" href="#imageCarousel">›</a>
        </div>
    }
</div>

<div class="tab-pane" id="files">
    <table class="table-bordered table-hover" width="100%">
        <tr>
            <th>
                Name
            </th>
            <th>
                Description
            </th>
            <th></th>
        </tr>
        @if (Model.Files.Count == 0)
        {
            <tr>
                <td colspan="3">
                    <span class="label label-info">No files attached to this order.</span>
                </td>
            </tr>
        }
        else
        {
            foreach (var file in Model.Files)
            {
            <tr>
                <td style="width: 40%">
                    <div class="pagelink" url="/attachment/downloadfile/@file.Id" href="#" data-toggle="tooltip" title="Click to download file">
                        <span>@file.Name</span>
                    </div>
                </td>
                <td style="width: 60%">
                    <div class="pagelink" url="/attachment/downloadfile/@file.Id" href="#" data-toggle="tooltip" title="Click to download file">
                        <span>@file.Description</span>
                    </div>
                </td>
                <td>
                    @if (Model.CanManage)
                    {
                        <a class="btn btn-danger" style="color: white" href="@Url.Action("DeleteFile", "Attachment", new { id = file.Id })">Delete</a>
                    }
                </td>
            </tr>
            }
        }
    </table>
</div>
